#include "Vida.h"
#include "GameOverException.h"
#include "SketcherHelper.h"
#include <string>



Vida::Vida(int cantInicial){
	this->colorVida = new Color("205","235","0");
	this->positionVida = new Position(70,3);
	this->cantidad = cantInicial;
}

Vida::~Vida(void){
	delete this->colorVida;
	delete this->positionVida;
}

void Vida::operator++() {
	this->cantidad++;
}

void Vida::operator--() {
	this->cantidad--;
	if(cantidad < 0) {
		throw GameOverException();
	}
}

int Vida::getCantidad(){
	return cantidad;
}
void Vida::setCantidad(int cantidad){
	this->cantidad=cantidad;
}
void Vida::draw(){
	string * strNumber = new string("");
	char bufferLine[5];
	_itoa_s(cantidad, bufferLine, 10);
	strNumber->append(bufferLine);
	SketcherHelper::getInstance()->clearBackground(this->positionVida, 10, 10);
	SketcherHelper::getInstance()->printText(this->positionVida,this->colorVida,strNumber->c_str());
	delete strNumber;
}
